import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import axios from 'axios';
import VueAxios from 'vue-axios';
import NProgress from 'nprogress';
Vue.use(VueAxios, axios);
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import myCharts from '@/assets/js/mychart'; //引入eCharts 文件
import '../src/assets/css/main.css';
Vue.use(ElementUI);
Vue.use(myCharts);
Vue.config.productionTip = false;

NProgress.configure({
	easing: 'ease', // 动画方式
	speed: 500, // 递增进度条的速度
	showSpinner: false, // 是否显示加载ico
	trickleSpeed: 200, // 自动递增间隔
	minimum: 0.3 // 初始化时的最小百分比
});

router.beforeEach((to, from, next) => {
	NProgress.start();
	if (to.path == '/login') {
		next();
	} else if (!localStorage.getItem('user')) {
		next({ path: '/login' });
	} else {
		next();
	}
});

router.afterEach(() => {
	NProgress.done();
});

new Vue({
	router,
	store,
	render: (h) => h(App)
}).$mount('#app');
